import javax.swing.tree.TreeNode;

/*
 * @lc app=leetcode.cn id=404 lang=java
 *
 * [404] 左叶子之和
 */

// @lc code=start
/**
 * Definition for a binary tree node.
 * public class TreeNode {
 *     int val;
 *     TreeNode left;
 *     TreeNode right;
 *     TreeNode(int x) { val = x; }
 * }
 */
class Solution {
    int sum=0;
    public int sumOfLeftLeaves(TreeNode root) {
        left(root);
        return sum;
    }
    void left(TreeNode root){
        if(root == null) return;//跳出条件
        if(root.left!=null){
            if(root.left.left==null && root.left.right==null)
                sum+=root.left.val;
        }
        left(root.left);
        left(root.right);
    }
}
// @lc code=end

